<?php 
$create_confirm_id=Yii::app()->params['create_confirm_id'];
$cs=Yii::app()->clientScript;
$cs->registerScript('appointment_to_confirm',<<<END
$(".to_confirm").click(
function(){
	var exists=true;
	var tab=parent.tab;
	var n = tab.getComponent('$create_confirm_id');
	if(n){
		exists=confirm('确认派车单窗口已存在，是否关闭已有窗口进行确认?');
		if(exists) tab.remove('$create_confirm_id');
		//else  tab.setActiveTab('$create_confirm_id');
	}
	if(exists){
		n = tab.add({'id':'$create_confirm_id','title':'确认派车单',	closable:true,height:'100px',
            html: "<iframe class='$create_confirm_id' scrolling='auto' frameborder='0' width='100%' height='100%' src='?r=confirm_sheet/create&aid=$model->id'></iframe>"});
        tab.setActiveTab(n);
	}
}
);
END
);
?>
<h2>派车单号: <?php echo $model->appointment_no; ?> </h2>

<div class="actionBar1">
<?php 
	if(isset($_GET['ok'])){
		if($_GET['ok']%2==0){//添加成功 
			$mess='添加成功！';
			
			if($_GET['ok']==2){//添加成功 并且由计划单导入
				$search_schedule_id=Yii::app()->params['search_schedule_id'];
				$update_schedule_id=Yii::app()->params['update_schedule_id'];
				$reminder_id=Yii::app()->params['reminder_id'];
				$cs=Yii::app()->clientScript;
				$cs->registerScript('schedule_to_appointment_ok',<<<END
				var app_iframe=[$(".$search_schedule_id",parent.document),$(".$update_schedule_id",parent.document),$(".$reminder_id",parent.document)];
				for(var i=0;i<app_iframe.length;i++){
					if(app_iframe[i].length>0){
						if(app_iframe[i].contents().find(".return_btn:first").length>0)
							 app_iframe[i].contents().find(".return_btn:first")[0].click();
						else
							 app_iframe[i].contents()[0].location.reload();
					}
				} 
END
				);
			}
			
			
		}
		else
			$mess='更新成功！'; 
		unset($_GET['ok']);
	}
	$act=isset($_GET['ret'])?$_GET['ret']:$ret;//判断show以后返回路径
	unset($_GET['ret']);unset($_GET['id']);
	$url=array($act)+$_GET;
?>
<?php $this->widget('application.extensions.print.printWidget',array('printedElement'=>'.dataGrid,H2'));?>&nbsp;&nbsp;&nbsp;&nbsp;
[<?php echo CHtml::link('确认','#',array('class'=>'to_confirm')); ?>]&nbsp;&nbsp;&nbsp;&nbsp;
[<?php echo CHtml::link('返回',$url,array('class'=>'return_btn')); ?>]
</div>

<table class="dataGrid" width="100%">
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('loading_status')); ?>
</th>
    <td width="80"><?php echo CHtml::encode($model->getLoadingStatusName()); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('truck_plate_no')); ?>
</th>
    <td width="70"><?php echo CHtml::encode($model->truck_plate_no); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('board_plate_no')); ?>
</th>
    <td width="80" ><?php echo CHtml::encode($model->board_plate_no); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('type')); ?>
</th>
    <td width="60"><?php echo CHtml::encode($model->type); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('driver1_name')); ?>
</th>
    <td><?php echo CHtml::encode($model->driver1_name); ?>
</td>

	<th class="label" ><?php echo CHtml::encode($model->getAttributeLabel('driver1_mobile')); ?>
</th>
    <td><?php echo CHtml::encode($model->driver1_mobile); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('driver2_name')); ?>
</th>
    <td><?php echo CHtml::encode($model->driver2_name); ?>
</td>

	<th class="label" ><?php echo CHtml::encode($model->getAttributeLabel('driver2_mobile')); ?>
</th>
    <td><?php echo CHtml::encode($model->driver2_mobile); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('business_time')); ?>
</th>
    <td  colspan="7"><?php echo CHtml::encode($model->business_time); ?>
</td>
</tr>
<?php if($model->loading_status==0):?><!-- 重驶 -->
<?php foreach($goods_models as $n=>$goods):?>
<tr>
<td colspan="8">货物信息<?php echo $n+1;?></td>
</tr>
<tr>
	<th class="label" ><?php echo CHtml::encode($goods->getAttributeLabel('consignor_name')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($goods->consignor_name); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('loading_place')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($goods->loading_place); ?>
</td>
</tr>

<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('consignee_name')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($goods->consignee_name); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('pod_place')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($goods->pod_place); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('consignor_link_name')); ?>
</th>
    <td ><?php echo CHtml::encode($goods->consignor_link_name); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('consignor_link_tel')); ?>
</th>
    <td ><?php echo CHtml::encode($goods->consignor_link_tel); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('consignee_link_name')); ?>
</th>
    <td ><?php echo CHtml::encode($goods->consignee_link_name); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('consignee_link_tel')); ?>
</th>
    <td ><?php echo CHtml::encode($goods->consignee_link_tel); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('goods_name')); ?>
</th>
    <td><?php echo CHtml::encode($goods->goods_name); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('pack_type')); ?>
</th>
    <td><?php echo CHtml::encode($goods->getPackTypeName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('unit_name')); ?>
</th>
    <td><?php echo CHtml::encode($goods->getUnitName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('amount')); ?>
</th>
    <td><?php echo CHtml::encode($goods->amount); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('time_costing')); ?>
</th>
    <td><?php echo CHtml::encode($goods->getTimeCostingName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('lift_kind')); ?>
</th>
    <td><?php echo CHtml::encode($goods->getLiftKindName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('origin')); ?>
</th>
    <td><?php echo CHtml::encode($goods->origin); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('destination')); ?>
</th>
    <td><?php echo CHtml::encode($goods->destination); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('path_mileage')); ?>
</th>
    <td><?php echo CHtml::encode($goods->path_mileage); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('fuel_name')); ?>
</th>
    <td><?php echo CHtml::encode($goods->getFuelName()); ?>
</td>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('driving_circuit')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($goods->getDrivingCircuitName()); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('demand_deliver_time')); ?>
</th>
    <td  colspan="2"><?php echo CHtml::encode($goods->demand_deliver_time); ?>
</td>

	<th class="label"><?php echo CHtml::encode($goods->getAttributeLabel('demand_arrival_time')); ?>
</th>
    <td  colspan="4"><?php echo CHtml::encode($goods->demand_arrival_time); ?>
</td>
</tr>
<?php endforeach;?>
<tr>
<td colspan="8">收入信息</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('amount_kind')); ?>
</th>
    <td><?php echo CHtml::encode($model->getAmountKindName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('advance_payment')); ?>
</th>
    <td><?php echo CHtml::encode($model->advance_payment); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('balance')); ?>
</th>
    <td ><?php echo CHtml::encode($model->balance); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('total_amount')); ?>
</th>
    <td ><?php echo CHtml::encode($model->total_amount); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('special_reasons')); ?>
</th>
    <td colspan="7"><?php echo CHtml::encode($model->special_reasons); ?>
</td>


</tr>
<?php else:?><!-- 指定空驶 -->
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('origin')); ?>
</th>
    <td><?php echo CHtml::encode($model->origin); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('destination')); ?>
</th>
    <td><?php echo CHtml::encode($model->destination); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('fuel_name')); ?>
</th>
    <td><?php echo CHtml::encode($model->getFuelName()); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('gas_amount')); ?>
</th>
    <td><?php echo CHtml::encode($model->gas_amount); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('gas_fee')); ?>
</th>
    <td><?php echo CHtml::encode($model->gas_fee); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('bridge_charge')); ?>
</th>
    <td><?php echo CHtml::encode($model->bridge_charge); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('extra_cost')); ?>
</th>
    <td><?php echo CHtml::encode($model->extra_cost); ?>
</td>

	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('total_cost')); ?>
</th>
    <td><?php echo CHtml::encode($model->total_cost); ?>
</td>
</tr>
<?php endif;?>
<?php if($model->loading_status==0):?><!-- 重驶 -->
<?php foreach($deadhead_models as $n=>$deadhead):?>
<tr>
<td colspan="8">提货行驶信息<?php echo $n+1;?></td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('origin')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->origin); ?>
</td>

	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('destination')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->destination); ?>
</td>

	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('mileage')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->mileage); ?>
</td>

	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('fuel_name')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->getFuelName()); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('gas_fee')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->gas_fee); ?>
</td>

	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('bridge_charge')); ?>
</th>
    <td ><?php echo CHtml::encode($deadhead->bridge_charge); ?>
</td>
	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('deadhead_reason')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->deadhead_reason); ?>
</td>
	<th class="label"><?php echo CHtml::encode($deadhead->getAttributeLabel('driving_circuit')); ?>
</th>
    <td><?php echo CHtml::encode($deadhead->getDrivingCircuitName()); ?>
</td>
</tr>
<?php endforeach;?>
<tr>
<td colspan="8">其他信息</td>
</tr>
<?php endif;?>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('mileage')); ?>
</th>
    <td><?php echo CHtml::encode($model->mileage); ?>
</td>
	<th><?php echo CHtml::encode($model->getAttributeLabel('driver_prepaid')); ?>
</th>
    <td><?php echo CHtml::encode($model->driver_prepaid); ?>
</td>
<?php if($model->loading_status==0):?>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('prepaid_place')); ?>
</th>
    <td colspan="3"><?php echo CHtml::encode($model->prepaid_place); ?>
</td>
<?php else:?>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('prepaid_place')); ?>
</th>
    <td><?php echo CHtml::encode($model->prepaid_place); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('driving_circuit')); ?>
</th>
    <td><?php echo CHtml::encode($model->getDrivingCircuitName()); ?>
</td>
<?php endif;?>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('create_time')); ?>
</th>
    <td><?php echo CHtml::encode($model->create_time); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('create_user')); ?>
</th>
    <td><?php echo CHtml::encode($model->create_user); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('update_time')); ?>
</th>
    <td><?php echo CHtml::encode($model->update_time); ?>
</td>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('update_user')); ?>
</th>
    <td><?php echo CHtml::encode($model->update_user); ?>
</td>
</tr>
<tr>
	<th class="label"><?php echo CHtml::encode($model->getAttributeLabel('remark')); ?>
</th>
    <td  colspan="7"><?php echo CHtml::encode($model->remark); ?>
</td>
</tr>
</table>
<?php if(isset($mess)) echo "<script>alert('$mess');</script>";?>
<div class="actionBar1">
<?php $this->widget('application.extensions.print.printWidget',array('printedElement'=>'.dataGrid,H2'));?>&nbsp;&nbsp;&nbsp;&nbsp;
[<?php echo CHtml::link('确认','#',array('class'=>'to_confirm')); ?>]&nbsp;&nbsp;&nbsp;&nbsp;
[<?php echo CHtml::link('返回',$url,array('class'=>'return_btn')); ?>]
</div>